package com.xiongwei.collection;

import java.time.DayOfWeek;
import java.util.EnumMap;
import java.util.Map;

/**
 * 如果Map的key是enum类型,推荐使用EnumMap,既保证速度,也不浪费空间
 * 使用EnumMap的时候,根据面向抽象编程的原则,应该持有Map接口
 *
 * @author XiongWei
 * @date 2021/1/7
 */
public class EnumMapUse {

    public static void main(String[] args) {
        Map<DayOfWeek, String> map = new EnumMap<DayOfWeek, String>(DayOfWeek.class);
        map.put(DayOfWeek.MONDAY, "周一");
        map.put(DayOfWeek.TUESDAY, "周二");
        map.put(DayOfWeek.THURSDAY, "周三");

        System.out.println(map);
        System.out.println(map.get(DayOfWeek.MONDAY));
    }
}
